/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Br.Com.Cds.Academia.DAO;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import javax.swing.JOptionPane;

/**
 *
 * @author Anatólio
 */


public class AcessoMySQL {
    
    Connection con;
    
    public static void main(String args[]){
    new AcessoMySQL();

}
    
    
    public Connection conectar(){
      try{
        Class.forName("com.mysql.jdbc.Driver");
        con = DriverManager.getConnection("jdbc:mysql://localhost:3306/bdacademia?user=root&password=4c3ss0");
        
    }catch(ClassNotFoundException ex){
        JOptionPane.showMessageDialog(null, "Não foi possível encontrar o Driver!");
    }catch(SQLException ex){
        ex.printStackTrace();
        JOptionPane.showMessageDialog(null, " Falha ao Conectar ao Banco de Dados ");
    }
      
      return con;

}
    
    public void desconectar(){
        try{
        con.close();
    }catch(SQLException ex){
        ex.printStackTrace();
    }
}
    
    
    public AcessoMySQL(){

}
    
}


